import { createRequest } from '/@/api/service';
const module = process.env.APP_EDITION === 'hgy' ? 'ib/base/v1/appMenu/' : 'ib/user/v1/appMenu/';

/**
 * @function app首页菜单查询
 * @param data
 * @param header
 * @returns {Promise}
 */
function APP_MENU_HOMEPAGE_QUERY(
  data: AppMenuApi.AppMenuHomepageQueryReq,
  header: object = {},
): Promise<AppMenuApi.AppMenuHomepageQueryResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}appMenuHomepageQuery`,
    data,
    header,
    'POST',
  );
}

/**
 * @function app菜单查询
 * @param data
 * @param header
 * @returns {Promise}
 */
function APP_MENU_QUERY(
  data: AppMenuApi.AppMenuQueryReq,
  header: object = {},
): Promise<AppMenuApi.AppMenuQueryResp> {
  return createRequest(`${process.env.APP_API_URL}${module}appMenuQuery`, data, header, 'POST');
}

/**
 * @function app菜单树查询(带权限)
 * @param data
 * @param header
 * @returns {Promise}
 */
function APP_MENU_TREE(
  data: Constants.ComQuery,
  header: object = {},
): Promise<AppMenuApi.AppMenuTreeResp> {
  return createRequest(`${process.env.APP_API_URL}${module}appMenuTree`, data, header, 'POST');
}

/**
 * @function app菜单树查询(无权限)
 * @param data
 * @param header
 * @returns {Promise}
 */
function APP_MENU_TREE_NO_PRI(
  data: Constants.ComQuery,
  header: object = {},
): Promise<AppMenuApi.AppMenuTreeNoPriResp> {
  return createRequest(`${process.env.APP_API_URL}${module}appMenuTreeNoPri`, data, header, 'POST');
}

export { APP_MENU_QUERY, APP_MENU_HOMEPAGE_QUERY, APP_MENU_TREE, APP_MENU_TREE_NO_PRI };
